import { _decorator, Component, Node, BoxCollider2D, Contact2DType, IPhysics2DContact, PolygonCollider2D } from 'cc';
const { ccclass, property } = _decorator;

/**
 * 水果(炸弹)碰撞脚本
 */
@ccclass('gameFruitCollider')
export class gameFruitCollider extends Component {

    private collider: PolygonCollider2D = null;

    onLoad() {
        this.collider = this.node.getComponent(PolygonCollider2D);

        this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
        console.log("gameFruitCollider onload")
    }

    onBeginContact (selfCollider: PolygonCollider2D, otherCollider: BoxCollider2D, contact: IPhysics2DContact | null) {
        // 只在两个碰撞体开始接触时被调用一次
        console.log('gameFruitCollider onBeginContact:self:{},other:{}',selfCollider,otherCollider);
    }

    start() {

    }

    update(deltaTime: number) {
        
    }
}


